import java.io.File;
import java.io.IOException;
import java.util.Date;
import java.util.Locale;

import beans.Album;
import beans.Artiste;
import beans.Lien;
import beans.Morceau;
import beans.Plateforme;
import beans.Playlist;
import beans.PlaylistMorceau;
import beans.Recherche;
import beans.Session;
import beans.Type;
import beans.User;
import beans.UserMorceau;

import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.ObjectWriter;

public class JsonFileTest {
	
	public static void main(String[] args) {
		User user = new User("1234L", "cool");
		Type type = new Type("type", "www.type.com");
		Artiste artiste = new Artiste("zeques", "ronan", "Sum41");
		Album album = new Album(1988, "ceci est un album", "heu");
		Morceau morceau = new Morceau("stairway to heaven", artiste, album, 10, 300);		
		Lien lien = new Lien("www.ok.fr", type, morceau);		
		Plateforme plateforme= new Plateforme("1234L", "cool", user, type);
		Playlist playlist = new Playlist("compilRoro", new Date(System.currentTimeMillis()));
		PlaylistMorceau playlistMorceau= new PlaylistMorceau(playlist, morceau, "descendant", Boolean.TRUE);
		Recherche recherche = new Recherche("mot-clef", new Date(System.currentTimeMillis()));
		Session session = new Session("srgsjkeekrgoergrger", 9000L);		
		UserMorceau userMorceau = new UserMorceau(10, new Date(System.currentTimeMillis()), user, morceau);
		
		ObjectMapper om = new ObjectMapper();
		ObjectWriter ow = om.writerWithDefaultPrettyPrinter();
		
		try {
			ow.writeValue(new File("src/main/resources/json/Album.json"), album);
			ow.writeValue(new File("src/main/resources/json/Artiste.json"), artiste);
			ow.writeValue(new File("src/main/resources/json/Lien.json"), lien);
			ow.writeValue(new File("src/main/resources/json/Morceau.json"), morceau);
			ow.writeValue(new File("src/main/resources/json/Plateforme.json"), plateforme);
			ow.writeValue(new File("src/main/resources/json/Playlist.json"), playlist);
			ow.writeValue(new File("src/main/resources/json/PlaylistMorceau.json"), playlistMorceau);
			ow.writeValue(new File("src/main/resources/json/Recherche.json"), recherche);
			ow.writeValue(new File("src/main/resources/json/Session.json"), session);
			ow.writeValue(new File("src/main/resources/json/Type.json"), type);
			ow.writeValue(new File("src/main/resources/json/User.json"), user);
			ow.writeValue(new File("src/main/resources/json/UserMorceau.json"), userMorceau);
			
			
		} catch (JsonGenerationException jge) {
			jge.printStackTrace();
		} catch (JsonMappingException jme) {
			jme.printStackTrace();
		} catch (IOException ioe) {
			ioe.printStackTrace();
		}
		
	}

}
